package com.bsfcs.rag.repository;

import com.bsfcs.rag.entity.Contract;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

@Repository
public interface DynamicContractRepository extends JpaRepository<Contract, String> {
    
    /**
     * 根据项目ID查询合同数据，支持动态字段查询
     * @param projectId 项目ID
     * @param fields 要查询的字段列表
     * @return 合同列表
     */
    @Query(value = "SELECT c FROM Contract c WHERE c.project = :projectId")
    List<Contract> findByProjectIdWithFields(@Param("projectId") String projectId, @Param("fields") Set<String> fields);
}